package com.igroupes.ovineherd.model.Style;

import com.igroupes.ovineherd.exception.ModelException;
import lombok.Data;

@Data
public class Group implements IStyle{
    String label;
    Object value;
    Boolean disabled; //禁用
    Boolean checked; //选中
    private Group(String name, Object value, Boolean disabled, Boolean checked) {
        this(name, value, disabled);
        this.checked = checked;
    }
    public Group(String name, Object value, Boolean disabled) {
        this(name, value);
        this.disabled = disabled;
    }
    public Group(String label, Object value) {
        this.label = label;
        this.value = value;
        this.disabled = false;
        this.checked =false;
    }

    public Group(){
    }

    @Override
    public Boolean verify(Object o) {
        if(!(o instanceof Group)){
            throw new ModelException("校验style类类型错误，group");
        }
        Group group = (Group) o;
        if(!(group.getChecked() instanceof Boolean)){
            throw new ModelException("checked值类型错误");
        }
        if(!(group.getDisabled() instanceof Boolean)){
            throw new ModelException("disabled值类型错误");
        }
        return true;
    }
}
